package com.mhuang.common.handler;

import com.mhuang.common.coder.ServerDecoder;
import com.mhuang.common.coder.ServerEncoder;
import com.mhuang.server.NettyServerHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class ServerChannelInitializerHandler extends ChannelInitializer<SocketChannel>{

	private static final ServerEncoder encoder = new ServerEncoder();
	
	public ServerChannelInitializerHandler(){
		super();
	}
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();  
		pipeline.addLast(encoder);
		pipeline.addLast(new ServerDecoder());	
		pipeline.addLast(new NettyServerHandler());
	}
}
